<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./newTemplate.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    
      
    <ui:define name="top"/>

    <ui:define name="left">
        <ui:include src="/inc/menu.xhtml"/>
    </ui:define>

    <ui:define name="content">
        <ui:include src="/inc/jscripts.xhtml"/>
        <h:form>
            <p:growl id="growl" showDetail="true" life="3000" />
            <p:panel header="Задания">
                
                <p:toolbar id="toolbar" styleClass="toolbar">
                    <p:toolbarGroup align="left">
                        <p:commandButton id="bnewjob" type="button" value="Создать" icon="ui-icon-document" styleClass="toolbarButton" onclick="addJob.show()"/>
                        <p:commandButton id="beditjob" type="button" value="Изменить" icon="ui-icon-pencil" styleClass="toolbarButton"/>
                        <p:commandButton id="bdeljob" type="button" value="Удалить" icon="ui-icon-close" styleClass="toolbarButton"/>
                    </p:toolbarGroup>
                    <p:toolbarGroup align="right">
                        <p:commandButton id="bstartjob" type="button" value="Старт" icon="ui-icon-play" styleClass="toolbarButton" />
                        <p:commandButton id="bstopjob" type="button" value="Стоп" icon="ui-icon-stop" styleClass="toolbarButton" />
                    </p:toolbarGroup>
                </p:toolbar>  
                <p:dataTable id="tableJobs" var="job" value="#{jobAction.jobs}" rowKey="#{job.id}" selection="#{jobAction.selectedJob}"
                             selectionMode="single" >
                    <p:column headerText="ID">
                        <h:outputText value="#{job.id}"/>
                    </p:column>
                    <p:column headerText="Наименование">
                        <h:outputText value="#{job.name}"/>
                    </p:column>
                    <p:column headerText="Сайт">
                        <h:outputText value="#{job.site}"/>
                    </p:column>
                    <p:column headerText="Таймер (сек.)">
                        <h:outputText value="#{job.timer}"/>
                    </p:column>
                    <p:column headerText="Запущен">
                        <h:outputText value="#{job.iswork}"/>
                    </p:column>


                </p:dataTable>
            </p:panel>

            <p:dialog widgetVar="addJob" header="Добавить задание" modal="true" hideEffect="fade" showEffect="fade"
                resizable="false" closable="false" width="30%">
              <p:panelGrid columns="2" columnClasses="panelGrid">
                  <p:outputLabel value="Наименование" style="font-weight: bold"/>    
                  <p:inputText required="true" value="#{jobAction.jobName}"/>

                  <p:outputLabel value="Сайт" style="font-weight: bold"/>    
                  <p:selectOneMenu value="#{jobAction.selectedSite}" effect="fade"> 
                      <f:selectItems value="#{jobAction.sites}"/>
                  </p:selectOneMenu>
                  
                  <p:outputLabel value="Jar файл" style="font-weight: bold"/>    
                  <p:inputText required="true" value="#{jobAction.jobJarFile}"/>

                  <p:outputLabel value="Таймер" style="font-weight: bold"/>
                  <p:inputMask mask="9?9999" placeHolder=" " style="float: right" value="#{jobAction.jobTimer}"/>

                  <p:outputLabel value="Запустить" style="font-weight: bold"/>
                  <p:selectBooleanCheckbox style="float: right" value="#{jobAction.jobStart}"/>
              </p:panelGrid>
              <p:commandButton value="OK" styleClass="dialogButtons" actionListener="#{jobAction.addJob}" 
                               oncomplete="addJobRequest(xhr, status, args)" update="tableJobs growl"/>
              <p:commandButton value="Oтмена" styleClass="dialogButtons" onclick="addJob.hide()"/>
          </p:dialog>
        </h:form>
        
        
        
        
    </ui:define>
    
</ui:composition>
